#include "qlabelex.h"



QLabelEx::QLabelEx(QWidget *parent)
    :QLabel(parent)//子类必须显式调用父类有参构造，否则父类的有参构造无法被调用
{
    pSlider = new QSlider(  (QWidget*)(this->parent())  );

    pSlider->setGeometry(QRect(10,20, 20, 100));

    pSlider->setOrientation(Qt::Vertical);
    pSlider->setMinimum(0);  // 最小值
    pSlider->setMaximum(200);  // 最大值
    pSlider->setSingleStep(1);  // 步长


    QString ss_str = "\
                QSlider::groove:vertical {\
                border: 1px solid #999999;\
                border-radius: 3px;\
                width: 5px;\
            }\
                QSlider::handle:vertical {\
                height: 20px;\
                width:15px;\
                background: rgb(0, 170, 255);\
            }";

    pSlider->setStyleSheet(ss_str);
    pSlider->hide();
}
QLabelEx::~QLabelEx()
{
    delete pSlider;
}

void QLabelEx::enterEvent(QEvent * event)
{
    qDebug()<<"enter";
    event->accept();
    pSlider->show();

}

void QLabelEx::leaveEvent(QEvent *event)
{
    event->accept();
    pSlider->hide();

}




